import random
from itertools import combinations

xing = ['赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫']

ming = ['', '高', '已', '亲', '其', '进', '此', '话', '常', '与', '活', '正', '感', '见', '明', '问', '力', '理', '尔', '点', '文', '几',
        '定', '本', '公', '特', '做', '外', '相', '西', '果', '走']

Ln = list(combinations(ming, 2))


def create_phone():
    # 第二位数字
    second = [3, 4, 5, 7, 8][random.randint(0, 4)]

    # 第三位数字
    third = {
        3: random.randint(0, 9),
        4: [5, 7, 9][random.randint(0, 2)],
        5: [i for i in range(10) if i != 4][random.randint(0, 8)],
        7: [i for i in range(10) if i not in [4, 9]][random.randint(0, 7)],
        8: random.randint(0, 9),
    }[second]

    # 最后八位数字
    suffix = random.randint(9999999, 100000000)

    # 拼接手机号
    return "1{}{}{}".format(second, third, suffix)


def random_email(emailType=None, rang=None):
    __emailtype = ["@qq.com", "@163.com", "@126.com", "@189.com"]
    # 如果没有指定邮箱类型，默认在 __emailtype中随机一个
    if emailType is None:
        __randomEmail = random.choice(__emailtype)
    else:
        __randomEmail = emailType
    # 如果没有指定邮箱长度，默认在4-10之间随机
    if rang is None:
        __rang = random.randint(4, 10)
    else:
        __rang = int(rang)
    __Number = "0123456789qbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPWRSTUVWXYZ"
    __randomNumber = "".join(random.choice(__Number) for i in range(__rang))
    _email = __randomNumber + __randomEmail
    return _email


with open("../Data.txt", "w", encoding="utf-8") as f:
    s = []
    t = set()
    e = set()
    for i in xing:
        for j in Ln:
            tij = create_phone()
            while tij in t:
                tij = create_phone()
            else:
                t.add(tij)

            eij = random_email()
            while eij in e:
                eij = random_email()
            else:
                e.add(eij)

            name = i + j[0] + j[1]
            s.append(name + "\t" + tij + "\t" + eij + "\t" + name + ".jpg" + "\t" + "200" + "\t" + "200")
    random.shuffle(s)
    f.write("\n".join(s))
